package com.soft.javase.day10.practice;

import java.util.function.Supplier;

/**
 * @author yzh
 * @desc TODO
 * @date 2025/5/4
 */
public class Max {
    public static void main(String[] args) {
        int[] arr = {33,22,55,11,66,90,14};

        int max = getMax(() -> {
            int maxValue = arr[0];
            for (int i = 1; i < arr.length; i++) {
                if (arr[i] > maxValue) {
                    maxValue = arr[i];
                }
            }
            return maxValue;
        });

        System.out.println("数组中的最大值是: " + max);
    }

    public static int getMax(Supplier<Integer> supplier) {
        return supplier.get();
    }
}
